
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}


$(function(){
	//调用播放
	runhomePlayer();
	$("#recruitId").val(GetQueryString("recruitId")==null?$("#recruitId").val():GetQueryString("recruitId"));
	//查询学生学习情况
	$.ajax({
		   type: "POST",
		   url: basePath + "/operation/runhome/findRecruitStudyInfo",
		   data:{recruitId:$("#recruitId").val()},
		   dataType:"json",
		   success: function(data){
			   data.studentCount= data.studentCount==null?0:data.studentCount;
			   data.belowPlanCount=  data.belowPlanCount==null?0:data.belowPlanCount;
			   data.abovePlanCount=  data.abovePlanCount==null?0:data.abovePlanCount;
			   data.avgTime=  data.avgTime==null?0:data.avgTime;
			   data.countTime= data.countTime==null?0:data.countTime;
			   $("#studentCount").text(data.studentCount);
			   $("#avgTime").text((data.avgTime/60/60).toFixed(1)==0.0?data.avgTime:(data.avgTime/60/60).toFixed(1));
			 $("#abovePlanCount").text(data.abovePlanCount);
			 $("#belowPlanCount").text(data.belowPlanCount);
			var countTimeAndstudentCount =((data.countTime/60/60).toFixed(1)==0.0?data.countTime:(data.countTime/60/60).toFixed(1))+"/";
			countTimeAndstudentCount += data.studentCount==null?0:data.studentCount;
			
			$("#countTimeAndstudentCount").text(countTimeAndstudentCount);
			if(data.studentCount==0){
				abovePlanCount=0;
				belowPlanCount=0;
			}else{
				var  abovePlanCount=data.belowPlanCount/data.studentCount*100;
				var belowPlanCount=(1-abovePlanCount/100)*100;
			}
			 $("#higherThanPlanned font").text(belowPlanCount.toFixed(0)+"%");
			 $("#lowerThanPlanned font").text(abovePlanCount.toFixed(0)+"%");
			 lowerThanPlanned();
			 higherThanPlanned();
			 if((data.avgTime/60/60)<0.05 && data.avgTime!=0) {
				 $(".number").html(zLocale.runhome_xuexixueshengzongshu_s);
				 $(".learningtime_p").html(zLocale.runhome_renjunxuexishijian_s);	
				 $("#countTimeAndstudentCount").text(data.countTime+"/"+data.studentCount);
			 }
			   
		   }
		});
	//查询论坛信息
	$.ajax({
		type: "GET",
		url: basePath + "/operation/runhome/findforums",
		data:{"recruitId":$("#recruitId").val()},
		dataType:"json", 
		success: function(data){
				var treenityPostActiveNumDtos=data.treenityPostActiveNumDtos;
			var stuActiveNumDtos=data.stuActiveNumDtos;
			$("#countForum").text(data.countForum==null?0:data.countForum);
		if(stuActiveNumDtos!=null && stuActiveNumDtos!="")	{
		for(var i=0;i<stuActiveNumDtos.length;i++){
				var html='<li class="portrait_img"><img title="'+stuActiveNumDtos[i].realname+'" src="'+stuActiveNumDtos[i].imgurl+'">'
							+'</li>'
			$("#stuimgurl").append(html);
				};
		}else{
			$("#stuimgurl").append("<p style='color:#666'>&nbsp;&nbsp;"+zLocale.runhome_wu+"</p>");
		}
		if(treenityPostActiveNumDtos!=null && treenityPostActiveNumDtos!="")	{
		for(var i=0;i<treenityPostActiveNumDtos.length;i++){
				var html='<li><a href="javascript:void(0);"><span class="arrow"></span>'
					+treenityPostActiveNumDtos[i].postTitle+'</a></li>';
				$("#FontScroll ul").append(html);	
			}
		}else{
			$("#FontScroll").append("<p style='color:#666'>"+zLocale.runhome_wu+"</p>");
			
		}
			 $('#FontScroll').FontScroll({time: 3000,num: 1});
		}
	});
	//查询见面课信息
	$.ajax({
		type: "POST",
		url: basePath + "/operation/runhome/findTeachingTaskList",
		data:{recruitId:$("#recruitId").val()},
		dataType:"json",
		success: function(data){
			var courseId=$("#courseId").val();
			var recruitId=$("#recruitId").val();
			if(data==null){
				return 
			}else{ 
				for(var i=0;i<data.length;i++){
					var time_hh_mm =  new Date(data[i].execiteTime).Format("hh:mm");
					var time_yy=  new Date(data[i].execiteTime).Format("yyyy-MM-dd");
					var time_h =  new Date(data[i].execiteTime).Format("hh");
					var time_m =  new Date(data[i].execiteTime).Format("mm");
					var video_time_h =parseInt(data[i].videoTime/60/60)<10?"0"+parseInt(data[i].videoTime/60/60):parseInt(data[i].videoTime/60/60)
					data[i].videoTime=data[i].videoTime==null?0:data[i].videoTime;
					var video_time_m =parseInt(data[i].videoTime/60)<10?"0"+parseInt(data[i].videoTime/60):parseInt(data[i].videoTime/60);
					if(data[i].videoTime<60 && data[i].videoTime!=0){
						video_time	="00"+zLocale.runhome_h+"00"+zLocale.runhome_m+(data[i].videoTime<10?("0"+data[i].videoTime):data[i].videoTime)+zLocale.runhome_s
					}else{
						video_time=	video_time_h+zLocale.runhome_h+video_time_m+zLocale.runhome_m

					}
					var html='<li>'
						+'	<p class="name" style="width:240px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="'+data[i].speakerStr+'">'+data[i].speakerStr+'</p>'
						+'<div class="innovative_div">'
						+'	<div class="innovativevideo_div">';
					var href='';
					var color='';
					var meet_type='';
					//1未开始   2 进行   3结束   4 预播 
					if(data[i].taskStatus=="3"){ 
						var coverPicture=data[i].coverPicture==null?'http://image.zhihuishu.com/testzhs/able-commons/demo/201612/6d3ac3a818c64270a17c7947c098f43a.png':data[i].coverPicture
						color='editred_ico'
						href='http://www.treenity.com/operation/scoredetail?meetCourseId='+data[i].meetCourseId+'&recruitId='+recruitId+'&id='+data[i].id+'&courseId='+courseId;
					html+='	<img'
								+' src="'+coverPicture+'">'
								+' <div class="videotransparentbg_div">'
								+' <a execiteTime="'+data[i].execiteTime+'" name="runhome_player" href="javascript:void(0);"  liveCourseId="'+data[i].liveCourseId+'" value="'+data[i].videoId+'">'
									+'	<p style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="'+data[i].taskName+'">'+data[i].taskName
										+'	</p>'
										+'	<div class="videotime_div clearfix">'
										+'		<span class="videoico fl"></span> <span class="time fr">'+video_time+'</span>'
											+'	</div>'
										+'	</a>'
									+'	</div>';
					}else if(data[i].taskStatus=="2")	{
						href="javascript:void(0);";
						color='editred_greenico'
						html+='		<div class="videotransparentbg_div1">'
							+' <a execiteTime="'+data[i].execiteTime+'" name="runhome_player" href="javascript:void(0);" liveCourseId="'+data[i].liveCourseId+'" value="doing">'
							+' <p style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="'+data[i].taskName+'">'+data[i].taskName
							+' </p> <span class="videoplay_ico"></span>'
							+' </a>'
							+' </div>';
						
					}else if(data[i].taskStatus=="1" ||data[i].taskStatus=="4")	{
						href="javascript:void(0);";
						color='editred_greenico'
						html+='	<div class="videotransparentbg_div2">'
							+' <a execiteTime="'+data[i].execiteTime+'" name="runhome_player" href="javascript:void(0)" liveCourseId="'+data[i].liveCourseId+'" value="no">'
							+' <p style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="'+data[i].taskName+'">'+data[i].taskName
							+' </p> <span class="openico">'+zLocale.runhome_kaiqi+'</span>'
							+' </a>'
							+' </div>'; 
						
					}		
									
							html+=' </div>'
							+' <div class="innovativetime_div">'
							+' <p class="clearfix">'
								+'	<span class="fl">'+time_yy+'</span><span class="fr">'+time_hh_mm+'</span>'
									+'	</p>'
								+' <a name="skip" href="'+href+'" class="'+color+'" meet_type="'+data[i].taskStatus+'"></a>'
								+' </div>'
							+' </div>'
							+' </li>';
						
						$("#facetoface").append(html);			
				}
			}
		}
	});
	
$("[name=skip]").live("click",function(){	
	if($(this).attr("meet_type")=="1"){
		layer.open({
			title:" ",
			icon:0,
			content:zLocale.runhome_jianmiankeweikaishi,
			shade:.6,
			skin: 'layui-layer-zhs',
			btn: [zLocale.public_confim] //按钮  
		});
	}else if($(this).attr("meet_type")=="2"){
		layer.open({
			title:" ",
			icon:0,
			content:zLocale.runhome_weijieshu,
			shade:.6,
			skin: 'layui-layer-zhs',
			btn: [zLocale.public_confim] //按钮  
		});
	}
});
	
	
	
});

//扩展时间格式方法
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
//播放



